#!/bin/bash
SERVICE_TENANT='ad112d1b866e4264a6c4490e98e7a7ab'
DEMO_TENANT='69ed8831fd474ce08d7cfcddede91029'
VLAN=121
# 외부 네트워크를 생성
neutron net-create --tenant-id $SERVICE_TENANT ext-network --shared --provider:network_type flat --provider:physical_network physnet1 --router:external=True
# 외부 네트워크용 subnet 을 생성
echo "Create Shared External Network"
neutron subnet-create ext-network 192.168.1.0/24 --tenant-id $SERVICE_TENANT --gateway 192.168.1.254 --disable-dhcp --allocation-pool start=192.168.1.60,end=192.168.1.69
 
# demo_router를 생성
echo "Create Demo Router for Tenant"
neutron router-create --tenant-id $DEMO_TENANT demo_router
# demo_router에 IP를 할당
echo "Attach Router Gateway Interface"
neutron router-gateway-set demo_router ext-network
 
neutron net-create --tenant-id $DEMO_TENANT private01 --provider:network_type vlan --provider:physical_network physnet2 --provider:segmentation_id $VLAN
 
neutron subnet-create --tenant-id $DEMO_TENANT --name private01-subnet --dns-nameserver 10.32.192.11 private01 192.168.4.0/24
neutron router-interface-add demo_router private01-subnet
